package com.kaver.dao;

import java.io.Serializable;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.Version;
import com.baomidou.mybatisplus.core.toolkit.ReflectionKit;
import com.baomidou.mybatisplus.core.toolkit.TableInfoHelper;
import com.baomidou.mybatisplus.extension.activerecord.Model;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;


@SuppressWarnings("rawtypes")
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public abstract class BaseModel extends Model {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * 创建时间
	 */
	@TableField(value = "create_time", fill = FieldFill.INSERT)
	private Long createTime;

	/**
	 * 更新时间
	 */
	@TableField(value = "update_time", fill = FieldFill.UPDATE)
	private Long updateTime;

	/**
	 * 乐观锁版本号
	 */
	@TableField(value = "version")
	@Version
	private Long version;

	/**
	 * 逻辑删除标志,1-已删除,0-未删除
	 */
	@TableField(value = "deleted", fill = FieldFill.INSERT_UPDATE)
	@TableLogic
	private String deleted;

	/**
	 * 主键值
	 */
	@Override
	protected Serializable pkVal() {
		return (Serializable) ReflectionKit.getMethodValue(this,
				TableInfoHelper.getTableInfo(getClass()).getKeyProperty());
	}

}
